SetTurnRatio
Sets the turn ratio of the current active motor
Contents
Syntax
SetTurnRatio(ratio)
Description
SetTurnRatio(ratio) sets the turn ratio of the current active motor which can be controlled by SendMotorSettings. The value ratio has to be wihtin the Integer interval -100...100. The value specifies the ratio of power distribution between two motors (e.g. left and right wheel of the robot). The ratio setting takes only affect with the next SendMotorSettings command and if two motors are synchronied with SyncToMotor.
According to the LEGO Mindstorms communication protocol documentation, a ratio of 0 means equal power to both motors. Set 50 if you want one wheel spinning and the other stopped. Turn ratio of 100 will turn one wheel in the opposite direction (i.e. reverse) and the other forward, hence giving the maximum "turn around on the spot" effect. Set values between 1 and 49 to get nice curves or circles driven by your robot.
Note:
When using several motor commands with SyncToMotor statements, unexpected behaviour can occur, due to the NXTs internal error correction counters. Sometimes it can help to issue the commands NXT_ResetMotorPosition(port, true), NXT_ResetMotorPosition(port, false) and StopMotor(port, 'off') for each of both motors. Although this seems like a waste of packets, this can do the trick, especially when working with certain turn ratios.
Example
SetMotor(MOTOR_B); SyncToMotor(MOTOR_A); SetPower(76); SetTurnRatio(50); SendMotorSettings();
See also
SendMotorSettings, SyncToMotor, SetMotor, SetPower
Signature
- Author: Linus Atorf, Alexander Behrens (see AUTHORS)
- Date: 2007/10/15
- Copyright: 2007-2008, RWTH Aachen University